package ewgenius.xube.engine.graphics.gui;

import org.lwjgl.util.Color;
import org.lwjgl.util.Rectangle;
import org.lwjgl.util.vector.Vector2f;

import ewgenius.xube.XubeEngine;
import ewgenius.xube.engine.graphics.Render;

public class Button extends Gui {

	protected Color backgroundColor = new Color(Color.RED);

	public Button(int width, int height, Gui parent) {
		this.width = width;
		this.height = height;
		this.parent = parent;
		activeArea = new Rectangle(0, 0, width, height);
	}

	public void render(Render render) {
		getPosition();
		for (Gui gui : children) {
			gui.render(render);
		}
		render.draw2DRect(new Vector2f(position.x - 1, position.y - 1),
				width + 2, height + 2, backgroundColor);
	}

	public void click() {
		XubeEngine.traceConsole("close");
		parent.close();
	}
	
	public void update(int time, XubeEngine engine) {
		getPosition();
		
		drag(engine);
	}
}
